import request from '@/utils/request'

//权限管理

/**
 * 获取用户权限数据
 * @param pram
 */
export function getPermissionById(pram) {
  // const data = { uid: pram.id ,show:true}
  return request({
    url: '/logistics/permission/get/list/tree',
    method: 'GET',
    params: pram
  })
}

/**
 * 获取全部权限数据
 * @param pram
 */
export function getAllPermissionForTree(pram) {
  const data = { isDel: !pram?null:pram.isDel ,show:!pram?true:pram.show}
  return request({
    url: '/logistics/permission/get/all/list/tree',
    method: 'GET',
    params: data
  })
}

/**
 * 添加权限
 * @param prams
 */
 export function permissionSave(prams) {
  const data ={
    id: prams.id,
    name: prams.name,
    type:prams.type,
    path: prams.path,
    permission:prams.permission,
    component:prams.component,
    pid: prams.pid,
    icon: prams.icon,
    sort:prams.sort,
    status: prams.status,
  }
  return request({
    url: '/logistics/permission/save',
    method: 'POST',
    data: data
  })
}

/**
 * 修改权限
 * @param prams
 */
 export function permissionUpdate(prams) {
  const data ={
    id: prams.id,
    name: prams.name,
    type:prams.type,
    path: prams.path,
    permission:prams.permission,
    component:prams.component,
    pid: prams.pid,
    icon: prams.icon,
    sort:prams.sort,
    status: prams.status,
  }
  return request({
    url: '/logistics/permission/update',
    method: 'PUT',
    data: data
  })
}

/**
 * 更新权限状态
 * @param prams
 */
 export function permissionUpdateStatus(prams) {
  const data ={
    // id: prams.id,
    state: prams.status
  }
  return request({
    url: `/logistics/permission/update/status/${prams.id}`,
    method: 'PUT',
    data: data
  })
}

/**
 * 删除权限
 * @param id
 */
 export function permissionDelete(id) {
  return request({
    url: `/logistics/permission/delete/${id}`,
    method: 'DELETE'
  })
}

